package com.example.administrator.maizuofilm.moviedetails.moviedetailsadapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.maizuofilm.R;
import com.example.administrator.maizuofilm.moviedetails.bean.DetailsComment;

import java.util.List;

/**
 * Created by hansen on 2016/7/14.
 */
public class DetailsCommentAdapter extends RecyclerView.Adapter<DetailsCommentAdapter.viewHold> {
    private Context context;
    private List<DetailsComment.DataBean> list;
    public DetailsCommentAdapter(Context context,List<DetailsComment.DataBean> list){
        this.context=context;
        this.list=list;

    }


    @Override
    public viewHold onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_commentdetails,null);
        viewHold hold=new viewHold(view);
        return hold;
    }

    @Override
    public void onBindViewHolder(viewHold holder, int position) {
        holder.commdetails_userName.setText(list.get(position).getAuthorName());
     // Date date=new Date(Long.valueOf(list.get(position).getReviewTime())*1000);
//      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//      String str= format.format(date);
        holder.commdetails_time.setText(list.get(position).getReviewTime());
        holder.commdetails_com.setText(list.get(position).getReviewContent());
        Glide.with(context).load(list.get(position).getAuthorHeadPic()).into(holder.comm_userPci);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class viewHold extends RecyclerView.ViewHolder {
TextView commdetails_userName,commdetails_time,commdetails_com;
        ImageView comm_userPci;

        public viewHold(View itemView) {
            super(itemView);
            commdetails_time= (TextView) itemView.findViewById(R.id.commdetails_time);
            commdetails_userName= (TextView) itemView.findViewById(R.id.commdetails_userName);
            comm_userPci= (ImageView) itemView.findViewById(R.id.comm_userPci);
            commdetails_com= (TextView) itemView.findViewById(R.id.commdetails_com);

        }
    }
}
